<?php
$this->breadcrumbs=array(
	'Monitorings',
);

$this->menu=array(
	array('label'=>'Monitoring','url'=>array('index'),'icon'=>'fa fa-list-alt', 'items' =>
		array(	
			array('label'=>'Create Monitoring','url'=>array('monitoring/create'),'icon'=>'fa fa-plus-circle'),
			array('label'=>'Manage Monitoring','url'=>array('admin'),'icon'=>'fa fa-tasks'),
		)
	)	
);

Yii::app()->clientScript->registerScript('search', "
	$('.search-button').click(function(){
		$('.search-form').toggle();
		return false;
	});
	$('.search-form form').submit(function(){
		$.fn.yiiGridView.update('monitoring-grid', {
			data: $(this).serialize()
		});
		return false;
	});
");
?>

<?php $box = $this->beginWidget(
    'bootstrap.widgets.TbBox',
    array(
        'title' => 'List Monitorings' ,
        'headerIcon' => 'icon- fa fa-list-ol',
        'headerButtons' => array(
            array(
                'class' => 'bootstrap.widgets.TbButtonGroup',
                'type' => 'success',
                // '', 'primary', 'info', 'success', 'warning', 'danger' or 'inverse'
                'buttons' => $this->menu
            ),
        ) 
    )
);?>
		<?php $this->widget('bootstrap.widgets.TbAlert', array(
		    'block'=>false, // display a larger alert block?
		    'fade'=>true, // use transitions?
		    'closeText'=>'&times;', // close link text - if set to false, no close link is displayed
		    'alerts'=>array( // configurations per alert type
		        'success'=>array('block'=>true, 'fade'=>true, 'closeText'=>'&times;'), //success, info, warning, error or danger
		        'info'=>array('block'=>true, 'fade'=>true, 'closeText'=>'&times;'), //success, info, warning, error or danger
		        'warning'=>array('block'=>true, 'fade'=>true, 'closeText'=>'&times;'), //success, info, warning, error or danger
		        'error'=>array('block'=>true, 'fade'=>true, 'closeText'=>'&times;'), //success, info, warning, error or danger
		        'danger'=>array('block'=>true, 'fade'=>true, 'closeText'=>'&times;'), //success, info, warning, error or danger
		    ),
		));
		?>
<?php 
//$this->renderPartial('_scan',array(
//	'model'=>$model,
//        )); 
?>
<?php //echo CHtml::link('Advanced Search','#',array('class'=>'search-button btn')); ?>
<div class="search-form" style="display:block">
	<?php $this->renderPartial('_search',array(
                    'model'=>$model,
        )); ?>
</div><!-- search-form -->

<?php $this->widget('bootstrap.widgets.TbGridView',array(
	'id'=>'monitoring-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'type' => 'striped hover', //bordered condensed
	'columns'=>array(
		array('header'=>'#','value'=>'($this->grid->dataProvider->pagination->currentPage*
					 $this->grid->dataProvider->pagination->pageSize
					)+
					array_search($data,$this->grid->dataProvider->getData())+1',
				'htmlOptions' => array('style' =>'width: 15px'),
		),
		array(
                    'header' => 'No Tiket',
                    'name' => 'noTiket',
                    'type' => 'raw',
                    'value' => '($data->noTiket)',
                ),
		'noDokumen',
		array(
                    'header' => 'No Polisi',
                    'name' => 'noPolisi',
                    'type' => 'raw',
                    'value' => '($data->noPolisi)',
                ),
		array(
                    'header' => 'Status Mobil',
                    'name' => 'statusMobil',
                    'type' => 'raw',
                    'value' => '($data->statusMobil)',
                ),
		array(
                    'header' => 'Status',
                    'name' => 'statusParkir',
                    'type' => 'raw',
                    'value' => '($data->statusParkir == 1 ? "Parking In" : ($data->statusParkir == 2 ? "Assign Gate" : ((!empty($data->timbanganKeluar) && $data->statusParkir == 0) ? "Mobil Out" : "Parking Out")))',
                ),

		array(
			'class'=>'bootstrap.widgets.TbButtonColumn',
			'template'=>'{assign}{load}{out}{finish}',
                        'htmlOptions' => array('style' =>'width: 90px'),
                        'buttons'=>array
                        (
                            'assign' => array
                            (
                                'label'=>'Assign Gate',
                                'icon'=>'fa fa-sign-in',
                                'url'=>'array("bongkarmuat/update","id"=>$data->tb_bongkar_muat_id)',
                                'visible'=>'(!empty($data->statusParkir) && empty($data->waktuMulai))',
                                'options'=>array(
                                    'class'=>'badge badge-info',
                                ),
                            ),
                            'load' => array
                            (
                                'label'=>'Confirm Un/Load End',
                                'icon'=>'fa fa-check-square-o',
                                'url'=>'array("bongkarmuat/load","id"=>$data->tb_bongkar_muat_id)',
                                'visible'=>'($data->statusParkir == 2 && empty($data->waktuSelesai))',
                                'options'=>array(
                                    'class'=>'badge badge-info',
                                ),
                            ),
                            'out' => array
                            (
                                'label'=>'Mobil Out',
                                'icon'=>'fa fa-sign-out',
                                'url'=>'array("monitoring/out","id"=>$data->id)',
                                'visible'=>'(empty($data->timbanganKeluar) && !empty($data->waktuSelesai))',
                                'options'=>array(
                                    'class'=>'badge badge-info',
                                ),
                            ),
                            'finish' => array
                            (
                                'label'=>'Info Detail',
                                'icon'=>'fa fa-info-circle',
                                'url'=>'array("monitoring/view","id"=>$data->id)',
                                'visible'=>'(!empty($data->timbanganKeluar) && !empty($data->waktuSelesai))',
                                'options'=>array(
                                    'class'=>'badge badge-info',
                                ),
                            ),
                        )
		),
	),
)); ?>

<?php $this->endWidget(); ?>